package com.example.aopweaver.dao;

import com.example.aopweaver.entity.UserEntity;
import lombok.Data;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.Mapping;

import javax.sql.DataSource;
import java.util.List;
import java.util.Map;

/**
 * @Author ifredomvip@gmail.com
 * @Date 2022/8/2 13:37
 * @Version 1.0.0
 * @Description
 **/

public class UserDao {

    private JdbcTemplate jdbcTemplate;

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public List<Map<String, Object>> getAllUser() {
        return jdbcTemplate.queryForList("select * from user");
    }

    public void insetOneUser() {
        String sql = "insert into user values(null,'ifredom','13577775432','1',null,null,1) ";
        jdbcTemplate.execute(sql);
    }

}
